/**
 * 投影类
 * @param {Number} min 投影内最小值
 * @param {Number} max 投影内最大值
 */
function Projection (min, max) {
    this.min = min || 0;
    this.max = max || 0;
}

Projection.prototype = {
    /**
     * 判断与指定投影是否有重合
     */
    overlaps: function (projection) {
        return this.max > projection.min && projection.max > this.min;
    },

    /**
     * 计算重叠量
     */
    overlap: function (projection) {
        if(this.max > projection.min && projection.max > this.min) {
            //有重合
            if(this.max > projection.min && this.max < projection.max) {
                return this.max - projection.min;
            }
            if(this.max > projection.max && projection.max > this.min) {
                return projection.max - this.min;
            }
        } else {
            return 0;
        }
    }
}